/**
 * 
 */
package GUI.main.navigation;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JPanel;

import GUI.main.MainClient;

/**
 * patient specific nav panel to be placed in nav panel.
 * 
 * @author mramsey3
 * 
 */
public class PatientNavigationMenuPanel extends JPanel implements
	ActionListener {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JPanel buttonPanel;
    private JPanel viewHistoryPanel;
    private JButton viewHistory;
    private JPanel logoutPanel;
    private JButton logoutButton;

    /**
     * 
     */
    public PatientNavigationMenuPanel() {
	super();
	setLayout(new BorderLayout());
	setPreferredSize(new Dimension(180, 450));
	add(getButtonPanel(), BorderLayout.CENTER);
    }

    /**
     * @return
     */
    private JPanel getButtonPanel() {
	if (buttonPanel == null) {
	    buttonPanel = new JPanel();

	    buttonPanel.setLayout(new BoxLayout(buttonPanel,
		    BoxLayout.PAGE_AXIS));
	    buttonPanel.add(Box.createVerticalStrut(200));
	    buttonPanel.add(getViewHistoryPanel());
	    buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
	    buttonPanel.add(getLogoutPanel());
	    buttonPanel.add(Box.createVerticalStrut(200));
	}
	return buttonPanel;
    }

    /**
     * @return
     */
    private JPanel getViewHistoryPanel() {
	if (viewHistoryPanel == null) {
	    viewHistoryPanel = new JPanel();
	    viewHistoryPanel.add(getViewHistory());
	}
	return viewHistoryPanel;
    }

    /**
     * @author mramsey3
     * @return
     */
    private JButton getViewHistory() {
	if (viewHistory == null) {
	    viewHistory = new JButton("View History");
	    viewHistory.setPreferredSize(new Dimension(180, 25));
	    viewHistory.setMargin(new Insets(0, 0, 0, 0));
	    viewHistory.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
	    viewHistory.putClientProperty("JButton.buttonType", "textured");
	    viewHistory.addActionListener(this);
	}
	return viewHistory;
    }

    /**
     * @return
     */
    private JPanel getLogoutPanel() {
	if (logoutPanel == null) {
	    logoutPanel = new JPanel();
	    logoutPanel.add(getLogoutButton());
	}
	return logoutPanel;
    }

    /**
     * @return
     */
    private JButton getLogoutButton() {
	if (logoutButton == null) {
	    logoutButton = new JButton("Logout");
	    logoutButton.setPreferredSize(new Dimension(180, 25));
	    logoutButton.setMargin(new Insets(0, 0, 0, 0));
	    logoutButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
	    logoutButton.putClientProperty("JButton.buttonType", "textured");
	    logoutButton.addActionListener(this);
	}
	return logoutButton;
    }

    /**
     * @author mramsey3
     * @param viewHistory
     */

    @Override
    public void actionPerformed(ActionEvent e) {
	if (e.getSource() == viewHistory) {

	} else if (e.getSource() == logoutButton) {
	    MainClient.logOut();
	}
    }

}
